<html>

<head>
  <title></title>
</head>

<body>

	<table border=1 align=center width=40%>
    	<tr>
        	<td>Mission
            </td>
        	<td>Red
            </td>
        	<td>Blue
            </td>
        </tr>
<?php

    include "kernel.php";

    $mis_r = mysql_query("select max(id) as id from mission");
    $mis = mysql_fetch_assoc($mis_r);
    $mis = $mis[id];
    $mis -= 300;

    $mis_r = mysql_query("select id,starttime,unix_timestamp(starttime) as ustart from mission where id>'$mis' order by id");

    while ($mis = mysql_fetch_assoc($mis_r)) {

	    $kill_r = mysql_query("select max(Team1) as red from killboard where MissionID=$mis[id]");
        $red = mysql_fetch_assoc($kill_r);
        $red = $red[red]+0;
        $totalred += $red;

	    $kill_r = mysql_query("select max(Team2) as blue from killboard where MissionID=$mis[id]");
        $blue = mysql_fetch_assoc($kill_r);
        $blue = $blue[blue]+0;
        $totalblue += $blue;

        if ($red>$blue)
	        echo "<tr bgcolor=red><td>$mis[id] ($mis[starttime], ".date("l",$mis[ustart]).")</td><td>$red</td><td>$blue</td></tr>";
        elseif ($red<$blue)
	        echo "<tr bgcolor=blue><td>$mis[id] ($mis[starttime], ".date("l",$mis[ustart]).")</td><td>$red</td><td>$blue</td></tr>";
        else
	        echo "<tr bgcolor=white><td>$mis[id] ($mis[starttime], ".date("l",$mis[ustart]).")</td><td>$red</td><td>$blue</td></tr>";
    }




?>
    <tr><td>Total:</td><td><?=$totalred;?></td><td><?=$totalblue?></td></tr>
	</table>
</body>

</html>